package com.anket.poll.model;

import java.util.ArrayList;
import java.util.List;

import com.anket.option.model.Option;
import com.anket.person.model.Person;

public class Poll {

	private long pollId;
	private String title;

	private Person person;
	private List<Option> allOptions;

	public long getPollId() {
		return pollId;
	}

	public void setPollId(long pollId) {
		this.pollId = pollId;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public Person getPerson() {
		return person;
	}

	public void setPerson(Person person) {
		this.person = person;
	}

	public List<Option> getAllOptions() {
		return allOptions;
	}
	
	public List<Option> getAllOptionsWithLimit(Integer limit){
		List<Option> newList=new ArrayList<Option>();
		int m=0;
		for(Option option:getAllOptions()){
			m++;
			if(m<=limit)newList.add(option);
			else{
				Option opt=new Option();
				opt.setContent("...");
				newList.add(opt);
				return newList;
			}
		}
		return newList;
	}

	public void setAllOptions(List<Option> allOptions) {
		this.allOptions = allOptions;
	}

}
